home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7132 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: news-m01.ny.us.ibm.net!usenet
  2. From: bbogard@ibm.net
  3. Newsgroups: comp.lang.c++,comp.lang.fortran
  4. Subject: Re: Calling C++ from FORTRAN on VMS
  5. Date: 21 Feb 1996 20:52:24 GMT
  6. Message-ID: <4gg0m8$401m@news-s01.ny.us.ibm.net>
  7. References: <31239D17.3159@stsci.edu>
  8. Reply-To: bbogard@ibm.net
  9. NNTP-Posting-Host: slip37-223-98.ibm.net
  10. X-Newsreader: IBM NewsReader/2 v1.2.5
  11.  
  12. In <31239D17.3159@stsci.edu>, Scott Stallcup <stallcup@stsci.edu> writes:
  13. >I need to call a C++ routine from a FORTRAN routine on both
  14. >VAX/VMS and AXP/VMS platforms.   
  15. >
  16. >The C++ documentation fails to mention mixed langage programs 
  17. >(other than calling C from C++)...
  18. >
  19. >Given the following example code, what compiler/linker options
  20. >will resolve the c++ reference ?
  21. >
  22. >---------------------------------------------------------------
  23. >      program tfor
  24. >c
  25. >      call tcxx ()
  26. >c
  27. >      end
  28. >---------------------------------------------------------------
  29. >
  30. >#include <stdio.h>
  31. >
  32. >void tcxx (void)
  33. > {
  34. >  printf ("Hello World\n");
  35. > }
  36. >
  37. >---------------------------------------------------------------
  38. >$ fortran tfor
  39. >$ cxx tcxx
  40. >$ link tfor,tcxx
  41. >%LINK-W-NUDFSYMS, 1 undefined symbol:
  42. >%LINK-I-UDFSYM,         TCXX 
  43. >%LINK-W-USEUNDEF, undefined symbol TCXX referenced
  44. >        in psect $LINK$ offset %X00000020
  45. >        in module TFOR 
  46. >$ 
  47. >
  48. >---------------------------------------------------------------
  49. >
  50. >Thanks,
  51. >
  52. >--------------------------------------
  53. >Scott Stallcup  (stallcup@stsci.edu)
  54. >Space Telescope Science Institute
  55.  
  56. I would think that the best way to attach the two source code systems, would be to 
  57. make a C interface that allows Fortan and C++ to talk.  This would mean that the app
  58. may not be able to be multi threaded, but I don't think that matters much.  All you need
  59. is the public symbol name, like _strcat, and a fortran linker that can like with public
  60. symbols generated from a c program.
  61.  
  62. I would not suggest that you try attaching Fortan and C++ directly.  Because of the '
  63. function tables of each object during runtime, 
  64.  
  65. Anyway, why not just port the fortran program to C or C++, unless of course you need
  66. imaginary number support.  Then you''l have to find an imaginary number class library.
  67.  
  68. Hope this helps.
  69.